import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';

import 'CardContainer.dart';


typedef callClick<T> = void Function(T obj);

///表示创建竖向  控件结构排版
class CardContainerVertical extends CardContainer {
  //CardContainerVertical({Key? key}) : super(key: key);
  Widget? rightContent;
  callClick? rightClick; //表示点击事件
  CardContainerVertical(
      {Key? key,
      label,
      labelAlign,
      labelStyle,
      labelIconSize,
      labelWitch,
      content,
      rightIcon,
      errorText,
      visible,
      leftIcon,
      isRequired = false,
      autoValidate = false,
      showLine = false,
      this.rightContent,
      readOnly,
      this.rightClick,
      labelSuffix})
      : super(
          key: key,
          label: label,
          labelAlign: labelAlign,
          labelStyle: labelStyle,
          labelIconSize: labelIconSize,
          labelWitch: labelWitch,
          content: content,
          errorText: errorText,
          visible: visible,
          leftIcon: leftIcon,
          rightIcon: rightIcon,
          isRequired: isRequired,
          autoValidate: autoValidate,
          showLine: showLine,
          labelSuffix: labelSuffix,
          readOnly: readOnly,
        );

  @override
  buildView(BuildContext context) {
    // TODO: implement buildView
    return _buildContainer(context);
  }

  Widget _buildContainer(BuildContext context) {
    return buildContainer(
        context,
        Column(
          children: [
            //GestureDetector
            InkWell(
              onTap: () {
                // if(rightClick!=null)
                rightClick?.call("");
              },
              //child: Container(
              //color: Colors.transparent,
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: buildLabelBlock(context),
                  ),
                  _buildRightContent(),
                  buildRightDecoration()
                ],
                // ),
              ),
            ),
            SizedBox(
              height: 12,
            ),
            buildDecoratedContent(context)
          ],
        ));
  }

  _buildRightContent() {
    return (rightContent != null)
        ? Container(alignment: Alignment.centerRight, child: rightContent)
        : Container();
  }
}
